/* 
 * File:   FileList.h
 * Author: faraj
 *
 * Created on September 26, 2009, 7:36 AM
 */

#ifndef _FILELIST_H
#define	_FILELIST_H
#include "../CTools/CTools.h"
#include "File.h"

class FileList
{
private:
    List<File*> fileList;
    
public:
    
    FileList()
    {
    }
    
    bool init()
    {
        
    }
    
    File* getFile(string hash)
    {
        File *file;
        for(int i=0;i<fileList.Size();i++)
        {
            file = fileList[i];
            if(file->checkHash(hash))
                return file;
        }
        return NULL;
    }
    
    void setFile(File *file)
    {
        fileList.Insert(0,file);
    }
    
    bool deleteFile(string hash)
    {
        File *file;
        for(int i=0;i<fileList.Size();i++)
        {
            file = fileList[i];
            if(file->checkHash(hash))
            {
                fileList.Remove(i);
                return true;
            }
        }
        return false;
    }
};

#endif	/* _FILELIST_H */

